﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using ProjectWebNhac.DAO;
using ProjectWebNhac.DTO;

namespace ProjectWebNhac.BUS
{
    public class AdminBus
    {
        Dataprovider dao = new Dataprovider();
        TheLoaiBus theloaiBus = new TheLoaiBus();
        CaSiBus casiBus = new CaSiBus();
        
        private DateTime laytimelogoutadmin()
        {
            DataTable dt = dao.LayDuLieuThamSo("sp_Admin_LayGioLogOutAdmin", CommandType.StoredProcedure);
            DateTime timelogout = DateTime.Parse(dt.Rows[0]["TimeLogOut"].ToString());
            return timelogout;
        }

        public int loadsothanhvienmoidangky()
        {
            DateTime timelogout = laytimelogoutadmin();
            DataTable dt2 = dao.LayDuLieuThamSo("sp_Admin_laysothanhvienmoiDK", CommandType.StoredProcedure, new object[] { "@TimeLogOut", timelogout });
            int soluong = int.Parse(dt2.Rows[0][0].ToString());
            return soluong;
        }

        public DataTable loadthanhvienmoidk()
        {
            DateTime timelogout = laytimelogoutadmin();
            DataTable dt2 = dao.LayDuLieuThamSo("sp_Admin_LayDSThanhVienMoiDKTop5", CommandType.StoredProcedure, new object[] { "@TimeLogOut", timelogout });
            return dt2;
        }

        public int loadsobaihatmoithem()
        {
            DateTime timelogout = laytimelogoutadmin();
            DataTable dt2 = dao.LayDuLieuThamSo("sp_Admin_laysobaihatmoithem", CommandType.StoredProcedure, new object[] { "@TimeLogOut", timelogout });
            int soluong = int.Parse(dt2.Rows[0][0].ToString());
            return soluong;
        }

        public DataTable loadaihatnmoithem()
        {
            DateTime timelogout = laytimelogoutadmin();
            DataTable dt2 = dao.LayDuLieuThamSo("sp_Admin_LayDSBaiHatMoiThemTop5", CommandType.StoredProcedure, new object[] { "@TimeLogOut", timelogout });
            return dt2;
        }

        public DataTable adminlogin(string TaiKhoan, string MatKhau)
        {
            DataTable dt = dao.LayDuLieuThamSo("sp_Admin_Login", CommandType.StoredProcedure, new object[] { "@TaiKhoan", TaiKhoan, "@MatKhau", MatKhau });
            return dt;
        }

        public bool capnhattimeoutadmin(string TaiKhoan)
        {
           bool i= dao.XuLySuKien("sp_Admin_TimeLogOut", CommandType.StoredProcedure, new object[] { "@TaiKhoan", TaiKhoan });
           return i;
        }
    }
}